<?php
namespace app\common\validate;

use app\common\enum\ArticleEnum;

/**
 * ArticleValidate
 */
class ArticleValidate extends BaseValidate
{
    protected $rule = [
        'author' => 'require',
        'article_time' => 'require|dateFormat:Y-m-d',
        'show_role' => 'require',
        'title' => 'require',
        'abstract' => 'require',
        'content' => 'require',
        'status' => 'require|in:0,1,2',
    ];

    private $article_type;

    public function __construct()
    {
        $this->article_type = array_keys( ArticleEnum::ARTICLE_TYPE);
        $this->article_type = implode(',', $this->article_type);
        $this->rule['article_type'] = 'require|in:'.$this->article_type;
        $this->message = [
            'author' => lang('author'),
            'article_time' => lang('article_time'),
            'show_role' => lang('show_role'),
            'article_type' => lang('article_type'),
            'title' => lang('title'),
            'abstract' => lang('abstract'),
            'content' => lang('content'),
            'status' => lang('status'),
        ];
        parent::__construct();
    }


    


    protected $scene = [
        'addArticle' => ['author', 'article_time', 'show_role', 'article_type', 'title', 'abstract', 'content'],
    ];
}